package demo;

import helloword.MyService;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;

import java.util.Date;
import java.util.Random;

class MyHandler implements MyService.Iface {

    @Override
    public int say(String content, int number) throws TException {
//        try {
//            Thread.sleep(10 * 1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        System.out.println("client call" + new Date());
        return 12;
    }
}

class MyAsyncHandler implements MyService.AsyncIface {

    @Override
    public void say(String content, int number, AsyncMethodCallback resultHandler) throws TException {
        System.out.println("Call " + content + " number " + number + " " + new Date());
        int i = new Random().nextInt(100);
        resultHandler.onComplete(i);
    }
}